#ifndef _MESSAGE_
#define _MESSAGE_
#include <string>

#include "platform\base.h"

#include "raknet\MessageIdentifiers.h"
#include "raknet\BitStream.h"
#include "raknet\RakString.h"

using namespace std;
using namespace RakNet;

enum PlatformID{
	ID_CREATE = ID_USER_PACKET_ENUM + 1,
	ID_CHECK_ROOM,
	ID_CHECK,
	ID_JOIN,
	ID_LEAVE,
	ID_READY,
	ID_READY_CANCEL,
	ID_GAME_START
};

struct PlatformMessage 
{
	virtual void Serialization(BitStream*, bool head = false) {}
	virtual void DeSerialization(BitStream*) {}
};

struct PlatformMessageCreate
{
	RakString username;
	virtual void Serialization(BitStream* bs, bool head = false) 
	{
		bs->Write((uchar)ID_CREATE);
		username.Serialize(bs);
	}
	virtual void DeSerialization(BitStream* bs) {
		uchar pid;
		bs->Read(pid);
		username.Deserialize(bs);
	}
};

struct PlatformMessageJoin
{
	RakString username;
	RakString roomname;
	virtual void Serialization(BitStream* bs, bool head = false) 
	{
		if (!head) bs->Write((uchar)ID_JOIN);
		username.Serialize(bs);
		roomname.Serialize(bs);
	}

	virtual void DeSerialization(BitStream* bs) {
		uchar pid;
		bs->Read(pid);
		username.Deserialize(bs);
		roomname.Deserialize(bs);
	}
};

#endif